package org.spark.sql.java.imooc;

import org.apache.spark.api.java.JavaSparkContext;
import org.apache.spark.sql.Dataset;
import org.apache.spark.sql.Row;
import org.apache.spark.sql.SQLContext;
import org.spark.sparkUtil.SparkJavaContextUtil;

/**
 * 功能概述:SQLContext的使用
 * Datetime:    2020/6/4   20:18
 * Author:   某人的目光
 */
public class SQLContextApp {
    public static void main(String[] args) {
        JavaSparkContext sparkContext = SparkJavaContextUtil.getSparkStart("SQLContextApp");

        SQLContext sqlContext = new SQLContext(sparkContext);

        Dataset<Row> df = sqlContext.read().format("json").load("D:\\学习Code\\大数据\\spark\\spark入门到精通\\spark-zero\\src\\main\\resources\\logs\\students.json");

        df.show();
        // +----+-------+
        // | age|   name|
        // +----+-------+
        // |null|Michael|
        // |  30|   Andy|
        // |  19| Justin|
        // +----+-------+

        sparkContext.close();
    }
}
